﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.Processs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sell.Api.Write.Application.Command.Pro;

namespace Sell.Api.Write.Controllers.Pro
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProController : ControllerBase
    {
        public IMediator mediator { get; }
        public ProController(IMediator _mediator)
        {
            mediator= _mediator;
        }
        /// <summary>
        /// 添加工序管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> ProAdd(IProAddCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工序管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiResult<int>> ProDel([FromQuery]IProDelCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工序管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> ProUpdate(IProUpdateCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工艺流程添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> FlowAdd(FlowAddCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工艺管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiResult<int>> FlowDel([FromQuery]FlowDelCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工艺流程修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> FlowUpdate(FlowUpdateCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
